﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="ManageDoctor.aspx.cs" Inherits="MyHospital.web.ManageDoctor" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
   <link  rel="stylesheet" href="Styles/docmanger.css"/>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server" >
    <div id="login" class="login">
             <!-- 登陆框标题 -->
             <div id="login-title" class="login-title">
                增加医生  
                 <span><a id="closeBtn" href="javascript:void(1)">关闭</a></span>
             </div>
            <!-- 登陆框表单 -->
           <table id="login-form" style="margin-left:150px">
                    <tr class="login-input">
                        <td><label>医生姓名：</label></td>
                        <td><asp:TextBox ID="txtInsertName" class="list-input" runat="server" Text="" ></asp:TextBox></td>
                        <td><asp:RequiredFieldValidator ControlToValidate="txtInsertName" Display="Dynamic" ForeColor="Red" ID="RequiredFieldValidator3" runat="server" ErrorMessage="必填"></asp:RequiredFieldValidator>
                    </tr>
                    <tr class="login-input">
                        <td><label>部门名称：</label></td>
                        <td><asp:DropDownList ID="dlsInsertDepart" class="list-input" runat="server" DataSourceID="LinqDataSource1" style="height: 35px;line-height: 35px;width: 350px;text-indent: 5px;" OnSelectedIndexChanged="dlsDepart1_SelectedIndexChanged" DataTextField="departName" DataValueField="departId"></asp:DropDownList></td>
                    </tr>
                    <tr class="login-input">
                        <td><label>年龄：</label></td>
                        <td><asp:TextBox ID="txtInsertAge" class="list-input" runat="server" Text=""></asp:TextBox></td>
                        <td><asp:RequiredFieldValidator ControlToValidate="txtInsertAge" Display="Dynamic" ForeColor="Red" ID="RequiredFieldValidator2" runat="server" ErrorMessage="必填"></asp:RequiredFieldValidator>
                    </tr>
                    <tr class="login-input1">
                        <td><label id="txtInsertSex" style="float: left;height: 35px;line-height: 35px;width: 90px;padding-left: 10px;text-align: right;font-size: 14px;">性别：</label></td>
                        <td>
                            <asp:RadioButton ID="RadioButton1" Text="男" runat="server" GroupName="Sex" />
                               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <asp:RadioButton ID="RadioButton2" Text="女" runat="server" GroupName="Sex"/>
                        </td>
                    </tr>
                    <tr class="login-input">
                        <td><label>电话：</label></td>
                        <td><asp:TextBox ID="txtInsertPhone" class="list-input" runat="server" Text=""></asp:TextBox></td>
                        <td><asp:RequiredFieldValidator ControlToValidate="txtInsertPhone" Display="Dynamic" ForeColor="Red" ID="rfvPhone" runat="server" ErrorMessage="必填"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="revPhone" runat="server" ErrorMessage="手机号码格式不正确！" ControlToValidate="txtInsertPhone" Display="Dynamic" ForeColor="Red" ValidationExpression="\d{11}">
                        </asp:RegularExpressionValidator></td>
                    </tr>
                    <tr class="login-input">
                        <td><label>职位：</label></td>
                        <td><asp:TextBox ID="txtInsertJob" class="list-input" runat="server" Text=""></asp:TextBox></td>
                        <td><asp:RequiredFieldValidator ControlToValidate="txtInsertJob" Display="Dynamic" ForeColor="Red" ID="RequiredFieldValidator4" runat="server" ErrorMessage="必填"></asp:RequiredFieldValidator>
                    </tr>
                    <tr class="login-input">
                        <td><label>简介：</label></td>
                        <td><asp:TextBox ID="txtInsertIntroduce" class="list-input" runat="server" Text=""></asp:TextBox></td>
                        <td><asp:RequiredFieldValidator ControlToValidate="txtInsertIntroduce" Display="Dynamic" ForeColor="Red" ID="RequiredFieldValidator6" runat="server" ErrorMessage="必填"></asp:RequiredFieldValidator>
                    </tr>
                   <tr class="login-input">
                        <td><label>照片：</label></td>
                        <td><asp:TextBox ID="txtInsertImage" class="list-input" runat="server" Text=""></asp:TextBox></td>
                       <td><asp:RequiredFieldValidator ControlToValidate="txtInsertImage" Display="Dynamic" ForeColor="Red" ID="RequiredFieldValidator5" runat="server" ErrorMessage="必填"></asp:RequiredFieldValidator>
                    </tr>
                   <tr>
                       <td></td>
                       <td><asp:Button ID="submitInsertDocter" class="loginSubmit" runat="server" Text="增加医生" OnClick="submitInsertDocter_Click"/>
                       </td>
                       <td><asp:Label ID="insertLable" runat="server" Text=""></asp:Label></td>
                   </tr>
               <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="MyHospital.DAL.MyHospitalDataContext" EntityTypeName="" TableName="Department">
               </asp:LinqDataSource>
                </table>
            </div>
            <!-- 遮盖层 -->
            <div id="bg" class="bg">sada</div>
    
    <!--医生名称:<asp:TextBox ID="txtDepartmentName" runat="server" Text=""></asp:TextBox>
&nbsp;<asp:Button ID="Search" runat="server" Text="搜索" OnClick="SearcheDoctor"/>
    <asp:Button ID="Back" runat="server" Text="取消" OnClick="SearchBack"/>
    &nbsp;&nbsp;&nbsp;-->
    <br />
    <br />
    <table>
        <tr>
            <td>
           <div class="mdleft">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="ldsDepartment" HorizontalAlign="Center" DataKeyNames="departId" style="margin-left:0px" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
        <Columns>
            <asp:BoundField DataField="departId" HeaderText="部门编号" ReadOnly="True" SortExpression="departId" ItemStyle-Width="60px" ItemStyle-Height="30px"/>

            <asp:BoundField DataField="departName" HeaderText="部门名称" ReadOnly="True" SortExpression="departName" ItemStyle-Width="200px"/>
            <asp:CommandField ShowSelectButton="True" ItemStyle-Width="30px"/>
        </Columns>
    </asp:GridView>
           </div>
                </td>
            <td>
                <div  class="mdright">
                     <asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="ldsDoctor" style="margin-top:0px;margin-left:0px" PageSize="3">
        <Columns>
            <asp:BoundField DataField="doctorId" HeaderText="医生编号" ReadOnly="True" SortExpression="doctorId" ItemStyle-Width="60px" ItemStyle-Height="30px"/>
            <asp:BoundField DataField="doctorName" HeaderText="医生姓名" ReadOnly="True" SortExpression="doctorName" ItemStyle-Width="60px"/>
            <asp:BoundField DataField="age" HeaderText="年龄" ReadOnly="True" SortExpression="age" ItemStyle-Width="30px"/>
            <asp:BoundField DataField="sex" HeaderText="性别" ReadOnly="True" SortExpression="sex" ItemStyle-Width="35px"/>
            <asp:BoundField DataField="phone" HeaderText="电话" ReadOnly="True" SortExpression="phone" ItemStyle-Width="60px"/>
            <asp:BoundField DataField="job" HeaderText="职位" ReadOnly="True" SortExpression="job" ItemStyle-Width="80px"/>
            <asp:BoundField DataField="introduce" HeaderText="简介" ReadOnly="True" SortExpression="introduce" ItemStyle-Width="360px"/>
            <asp:ImageField DataImageUrlField="image" HeaderText="照片" ReadOnly="True"  SortExpression="image" ItemStyle-Width="60px"/>
                        <asp:TemplateField ItemStyle-Width="40px">
                    <ItemTemplate>
                        <input type="radio" name="myRadio" value='<%# Container.DataItemIndex.ToString() %>'>
                        </form>
                    </ItemTemplate>
<ItemStyle Width="40px"></ItemStyle>
                </asp:TemplateField>
        </Columns>
    </asp:GridView>
                </div>
   
                </td>
            </tr>
        </table>
    <asp:LinqDataSource ID="ldsDepartment" runat="server" ContextTypeName="MyHospital.DAL.MyHospitalDataContext" EntityTypeName="" Select="new (departId, departName)" TableName="Department" EnableDelete="True" EnableInsert="True" EnableUpdate="True">
    </asp:LinqDataSource>
    
    <asp:LinqDataSource ID="ldsDoctor" runat="server" ContextTypeName="MyHospital.DAL.MyHospitalDataContext" EntityTypeName="" EnableDelete="True" EnableInsert="True" EnableUpdate="True"
        Select="new (doctorId, doctorName, departId, age, sex, phone, job, introduce, image)" TableName="Doctor" Where="departId == @departId">
        <WhereParameters>
            <asp:ControlParameter ControlID="GridView1" DefaultValue="1" Name="departId" PropertyName="SelectedValue" Type="Int32" />
        </WhereParameters>
    </asp:LinqDataSource>
        <script type="text/javascript">
            function setNowRadio(v)
            {
                //alert(v);
                var myForm,objRadio;
                myForm=document.forms[0];
                for(var i=0;i<myForm.length;i++)
                {
                    if(myForm.elements[i].type=="radio")
                    {
                        objRadio=myForm.elements[i];
                        //alert(objRadio.name);
                        //alert(objRadio.value);
                        if(objRadio.value==v)
                        {
                            objRadio.checked=true;
                        }
                    }
                }
            }
            <asp:Literal ID="jsLiteral" runat="server"></asp:Literal>
        </script>
        <table class="Department"  style="margin-top:20px;margin-left:0px">
        <tr >
            <td>
                <a id="insertBtn" href="javascript:void(0)">
                    <asp:Button ID="insertDoctor" runat="server" Text="增加医生" Width="100px" href="javascript:void(0)" OnClick="insertDoctor_Click"/>
                </a>
            </td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp</td>
            <td>
                <a>
              <asp:Button ID="deleteDoctor" runat="server" Text="删除医生" Width="100px" OnClick="deleteDoctor_Click" OnClientClick="javascript:return confirm('真的要删除吗？');"/>
                    </a>
            </td>
                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp</td>
            <td>
                <a>
              <asp:Button ID="updateDoctor1" runat="server" Text="编辑医生" Width="100px" OnClick="updateDoctor1_Click"/>
                 </a>
            </td>
           </tr>
            <tr>
                <td>
                   <asp:Label ID="lblMassage" runat="server" ForeColor="Red"></asp:Label>
                </td>
            </tr>
        </table>
    
                <script type="text/javascript">
                    var login = document.getElementById('login');
                    //  .点击"点击，弹出登陆框",弹出登陆窗口和遮盖层
                    var adminBtn = document.getElementById('insertBtn');
                    adminBtn.onclick = function () {
                        login.style.display = "block";
                        bg.style.display = "block";
                        return false;
                    }
                    //  .点击"关闭",隐藏登陆窗口和遮盖层
                    var closeBtn = document.getElementById('closeBtn');
                    closeBtn.onclick = function () {
                        login.style.display = "none";
                        bg.style.display = "none";
                        return false;
                    }
                    //  .鼠标拖拽功能
                    var login_title = document.getElementById('login-title');
                    login_title.onmousedown = function (e) {
                        e = e || window.event;
                        var x = e.pageX || e.clientX + (document.body.scrollLeft || document.documentElement.scrollLeft);
                        var y = e.pageY || e.clientY + (document.body.scrollTop || document.documentElement.scrollTop);

                        var boxX = login.offsetLeft;
                        var boxY = login.offsetTop;

                        var mouse_in_boxX = x - boxX;
                        var mouse_in_boxY = y - boxY;

                        document.onmousemove = function (e) {
                            var x = e.pageX || e.clientX + (document.body.scrollLeft || document.documentElement.scrollLeft);
                            var y = e.pageY || e.clientY + (document.body.scrollTop || document.documentElement.scrollTop);

                            login.style.left = x - mouse_in_boxX + +'px';
                            login.style.top = y - mouse_in_boxY - +'px';
                        }
                    }

                    login_title.onmouseup = function () {
                        document.onmousemove = null;
                    }
                </script>   
    <script type="text/javascript">
        function fun1() {

            var radios = document.getElementsByName("myRadio");
            var tag = false;
            var val;
            for (radio in radios) {
                if (radios[radio].checked) {
                    tag = true;
                    val = radios[radio].value;
                    break;
                }
            }
            if (tag) {
                alert(val)
                return true;
            }
            else {
                alert("请选择。。。。");
                return false;
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">

</asp:Content>
